<?php include("include/textcenter.php"); ?>
<?php include("include/db.php"); ?>
<?php include("include/fn.php"); ?>
<?php
    $CustomerID = $_POST['CustomerNo'];
    $FirstName = $_POST['FirstName'];
    $LastName = $_POST['LastName'];
    $Phone = $_POST['Phone'];
    $Email = $_POST['Email'];
?>
<html>
<head>
<meta name="description" content="Admin<?php echo $tagdescription?>">
<meta name="keywords" content="<?php echo $tagkeywords?> Main">
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Customer List -<?php echo $tagtitle?></title>
<script type="text/javascript" src="simpletreemenu.js">
/***********************************************
* Simple Tree Menu- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
<link rel="stylesheet" type="text/css" href="simpletree.css" />
<link rel="StyleSheet" href="include/css_classes.css" type="text/css">
</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" link="#0000FF" vlink="#800080" alink="#FF0000" bgcolor="#FFFFFF">
<!-- -------------------Header---------------------------- -->
<?php include("include/header.php"); ?>
<!-- -------------------End Header---------------------------- -->
<div align="center">
<table border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="12%" valign="top">
		<img border="0" src="public/images/homepage/spider16.gif" width="200" height="1"></td>
		<td width="1%" valign="top">
		<img border="0" src="public/images/homepage/spider16.gif" width="16" height="1"></td>
		<td width="86%" valign="top">
		<img border="0" src="public/images/homepage/spider16.gif" width="16" height="1"></td>
	</tr>	
	<tr>
		<!-- ///////////////////Begin Leftmenu/////////////////// -->
		<td width="12%" valign="top" bgcolor="#FFFFFF">
		<?php include("include/leftmenu.php"); ?>
		</td>
		<!-- ///////////////////End Leftmenu/////////////////// -->
		
		<td width="1%" valign="top" background="public/images/homepage/16.gif">&nbsp;</td>
		<td width="86%" valign="top">
	<br>
<!-- -------------------Begin Body---------------------------- -->
<form name="search" method="post" action="customer_search.php">
    <table>
        <tr>
            <td colspan="2">
                <p class="title16B">Search customer</p>
            </td>
        </tr>
        <tr>
            <td>
                CustomerID
            </td>
            <td>
                <input type="text" name="CustomerNo" />
            </td>
        </tr>
        <tr>
            <td>
                First name
            </td>
            <td>
                <input type="text" name="FirstName" />
            </td>
        </tr>
        <tr>
            <td>
                Last name
            </td>
            <td>
                <input type="text" name="LastName" />
            </td>
        </tr>
        <tr>
            <td>
                Phone
            </td>
            <td>
                <input type="text" name="Phone" />
            </td>
        </tr>
        <tr>
            <td>
                Email
            </td>
            <td>
                <input type="text" name="Email" />
            </td>
        </tr>
        <tr>
            <td>
            </td>
            <td>
                <input type="submit" name="SubmitSearch" value="Search" />
            </td>
        </tr>
    </table>
</form>

<p class="title16B">&nbsp;Customer &nbsp;-<a href="customer_add.php">Add +</a></p>
<?php
$page_name="customer_list.php"; //  If you use this code with a different page ( or file ) name then change this 
//$start=$_GET['start'];
if(empty($_GET['start'])) 
$start=0;
    //echo "No GET variables"; 
else 
$start=$_GET['start'];
  //  print_r($_GET); 
if(strlen($start) > 0 and !is_numeric($start)){
echo "Data Error";
exit;
}
$eu = ($start - 0); 
$limit = 90;                                 // No of records to be shown per page.
$this1 = $eu + $limit; 
$back = $eu - $limit; 
$next = $eu + $limit; 
/////////////// WE have to find out the number of records in our table. We will use this to break the pages///////
$query2=" SELECT * FROM vnf_customer where 1";
if($CustomerID!="")
{
    $query2 .= " AND CustomerNo='$CustomerID'";
}
if($FirstName!="")
{
    $query2 .= " AND FirstName like '%$FirstName%'";
}
if($LastName!="")
{
    $query2 .= " AND LastName like '%$LastName%'";
}
if($Phone!="")
{
     $query2 .= " AND Phone like'%$Phone%'";
}
if($Email!="")
{
     $query2 .= " AND Email like'%$Email%'";
}
//echo $query2;
$result2=mysql_query($query2);
echo mysql_error();
$nume=mysql_num_rows($result2);
/////// The variable nume above will store the total number of records in the table////
?>
<?php
		/////////////////////////////// 
if($nume > $limit ){ // Let us display bottom links if sufficient records are there for paging

//-------------------------------------------------page------------------------------------------------------------
/////////////// Start the bottom links with Prev and next link with page numbers /////////////////
echo "<table align = 'center' width='700'><tr><td>";
//// if our variable $back is equal to 0 or more then only we will display the link to move back ////////
if($back >=0) { 
print "<a href='$page_name?start=$back'><font face='Verdana' size='2'>PREV</font></a>"; 
} 
//////////////// Let us display the page links at  center. We will not display the current page as a link ///////////
$i=0;
$l=1;
for($i=0;$i < $nume;$i=$i+$limit){
if($i <> $eu){
echo " <a href='$page_name?start=$i'><font face='Verdana' size='2'>$l</font></a> ";
}
else { echo "<font face='Verdana' size='4' color=red>$l</font>";}        /// Current page is not displayed as link and given font color red
$l=$l+1;
}
///////////// If we are not in the last page then Next link will be displayed. Here we check that /////
if($this1 < $nume) { 
print "<a href='$page_name?start=$next'><font face='Verdana' size='2'>NEXT</font></a>";} 

echo "</td></tr></table>";
}// end of if checking sufficient records are there to display bottom navigational link. 
//---------------------------------------------end page-----------------------------------------------------------
	?>	
		<table border="0" width="100%" bgcolor="#E0E0E0" bordercolor="#000000">
	<tr>
			<td width="100" bgcolor="#CC6699"><b>ID</b></td>
		<td width="100" bgcolor="#CC6699"><b>First Name</b></td>
				<td width="100" bgcolor="#CC6699"><b>Last Name</b></td>
				<td width="150" bgcolor="#CC6699"><b>Email</b></td>
				<td align="center" width="150" bgcolor="#CC6699"><b>Phone</b></td>
		<td width="100" bgcolor="#CC6699"><b>Since</b></td>
		<td width="250" bgcolor="#CC6699"><p align="right"><b>Credit</b></td>
	</tr>
<?php 
$bgcolor ="fde8f2";
////////////// Now let us start executing the query with variables $eu and $limit  set at the top of the page///////////
/*$query=" SELECT * FROM vnf_customer where CustomerNo='$CustomerID' 
or FirstName like '%$FirstName%' or LastName like '%$LastName%' or Phone like'%$Phone%' order by CustomerNo desc limit $eu, $limit ";*/
$query=" SELECT * FROM vnf_customer where 1";
if($CustomerID!="")
{
    $query = " AND CustomerNo='$CustomerID'";
}
if($FirstName!="")
{
    $query .= " AND FirstName like '%$FirstName%'";
}
if($LastName!="")
{
    $query .= " AND LastName like '%$LastName%'";
}
if($Phone!="")
{
     $query .= " AND Phone like'%$Phone%'";
}
if($Email!="")
{
     $query .= " AND Email like'%$Email%'";
}
$query .= " order by CustomerNo desc limit $eu, $limit";

//echo $query;

$result=mysql_query($query);
//echo $query;
echo mysql_error();

//////////////// Now we will display the returned records in side the rows of the table/////////
while($row = mysql_fetch_array($result))
{

$CustomerNo =$row['CustomerNo'];
$LastName=$row['LastName'];
$FirstName=$row['FirstName'];
$Phone=$row['Phone'];
$Email=$row['Email'];
$Since=strtotime($row['Since']);
$Since = date("m/d/Y",$Since); 
$StoreCredit=$row['StoreCredit'];	
$status=$row['status'];	
$password = $row['Password'];
?> 	
	<tr>
			<td width="100" bgcolor="#<?php echo $bgcolor?>"><?php echo $CustomerNo ?></td>
		<td width="100" bgcolor="#<?php echo $bgcolor?>">
        <a target="_blank" href="<?php
        echo BASE_URL.'/index/shop/customerprocess?id='.$CustomerNo;
        ?>
        "><?php echo $FirstName?>
        </a>
        <!--<a href="customer_detail.php?id=<?php //echo $row['CustomerNo'] ?>"></a>--> 
        </td>
				<td width="100" bgcolor="#<?php echo $bgcolor?>">
            <a target="_blank" href="<?php echo BASE_URL.'/index/shop/customerprocess?id='.$CustomerNo;?>">
        <?php echo $LastName?>
        </a>
               <!--<a href="customer_detail.php?id=<?php //echo $row['CustomerNo'] ?>"> <?php //echo $LastName?> </a>-->
                </td>
				<td width="150" bgcolor="#<?php echo $bgcolor?>"><?php echo $Email?> </td>
				<td align="center" width="150" bgcolor="#<?php echo $bgcolor?>">
				<?php echo $Phone?>&nbsp;
		<td width="100" bgcolor="#<?php echo $bgcolor?>"><?php echo $Since?></td>
	<td width="250" bgcolor="#<?php echo $bgcolor?>"><p align="right"><?php echo $StoreCredit?>
	&nbsp;<img border="0" src="public/images/homepage/<?php echo $status?>.gif">&nbsp;
					<a href="customer_edit.php?CustomerNo=<?php echo $CustomerNo?>&start=<?php echo $start?>">Edit</a> - 
				<a href="customer_delete.php?CustomerNo=<?php echo $CustomerNo?>&start=<?php echo $start?>">Delete</a>-
	     <a href="customer_add_order.php?id=<?php echo $CustomerNo?>">Add new order</a>
	</td> 	
		</td>
	</tr>
	<?php 
	if ($bgcolor =="fde8f2")
 $bgcolor ="FFFFFF";
else  $bgcolor ="fde8f2";
}; 
?>
</table>
<!-- -------------------End Body---------------------------- -->
&nbsp;</td>
	</tr>

</table>
</div>
<!-- ----------------------------------------------- -->
<!-- \\\\\\\\\\\\\\\\\\\\\Begin Footer\\\\\\\\\\\\\\\\\\\\\ -->
<?php include("include/footer.php"); ?>
<!-- \\\\\\\\\\\\\\\\\\\\\End Footer\\\\\\\\\\\\\\\\\\\\\ -->
</body>

</html>